﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Space.Library;

namespace TestProject1
{
    [TestClass]
    public class MathTests  
    {
        [TestMethod]
        public void TestLength()
        {
            Assert.AreEqual((float)Math.Sqrt(2), new Vector2D(1, 1).Length());
            Assert.AreEqual((float)Math.Sqrt(8), new Vector2D(2, 2).Length());
            Assert.AreEqual(0, new Vector2D(0, 0).Length());
        }

        [TestMethod]
        public void TestDot()
        {
            Assert.AreEqual(2, new Vector2D(1, 1) * (new Vector2D(1, 1)));
            Assert.AreEqual(0, new Vector2D(0, 0) * (new Vector2D(1, 1)));
            Assert.AreEqual(8, new Vector2D(2, 2) * (new Vector2D(2, 2)));
            Assert.AreEqual(4, new Vector2D(1, 1) * (new Vector2D(2, 2)));
        }

        [TestMethod]
        public void TestAngleFromVerticalToVector()
        {
            Assert.AreEqual(0d, Math.Round(new Vector2D(0, 0).FindAngleToTarget(new Vector2D(0, 1))));
            Assert.AreEqual(45d, Math.Round(new Vector2D(0, 0).FindAngleToTarget(new Vector2D(1, 1))));
            Assert.AreEqual(90d, Math.Round(new Vector2D(0, 0).FindAngleToTarget(new Vector2D(1, 0))));
            Assert.AreEqual(135d, Math.Round(new Vector2D(0, 0).FindAngleToTarget(new Vector2D(1, -1))));
            Assert.AreEqual(180d, Math.Round(new Vector2D(0, 0).FindAngleToTarget(new Vector2D(0, -1))));
            Assert.AreEqual(225d, Math.Round(new Vector2D(0, 0).FindAngleToTarget(new Vector2D(-1, -1))));
            Assert.AreEqual(270d, Math.Round(new Vector2D(0, 0).FindAngleToTarget(new Vector2D(-1, 0))));
            Assert.AreEqual(315d, Math.Round(new Vector2D(0, 0).FindAngleToTarget(new Vector2D(-1, 1))));       
        }
    }
}
